<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <div id="app">
      <input type="text" v-model='firstName'>
      <input type="text" v-model='lastName'>
      <input type="text" v-model='fullName'>
      <hr>
      <h2>computed: {{allName}}</h2>

      <input type="text" v-model='Number'>
  </div>
  <script src="./vue.js"></script>
  <script>
    var vm = new Vue({
      el:'#app',
      data:{
          firstName: 'mike',
          lastName:'jason',
          fullName:'',
          Number:1
      },
      watch: {
          firstName(newVal,oldVal) {
              console.log('new: ' + newVal);
              console.log('old: ' + oldVal);
              this.fullName = newVal + this.lastName
          },
          lastName(newVal,oldVal) {
              this.fullName = this.firstName + newVal
          }
      },
      computed:{
          allName() {
              console.log('run')
              return this.firstName + this.lastName
          }
      }
     });
  </script>
</body>
</html>
